//
//  CoreDataManager.h
//  gweAD
//
//  Created by Marx on 2016/10/31.
//  Copyright © 2016年 mengy. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "AppDelegate.h"


typedef NS_ENUM(NSInteger ,CoreDataOperationResult){
    CoreDataOperationSucceeded=0,//成功
    CoreDataOperationNoMatching = 1,//没有符合条件
    CoreDataOperationFailed = -1//失败
};

@interface CoreDataManager : NSObject

+ (CoreDataManager *)sharedCoreDataManager;


/**
 插入

 @param entityName 实体名
 @param dataDic 数据
 @return 操作结果
 */
- (CoreDataOperationResult)insertCoreDataWithEntityName:(NSString *)entityName andDataDic:(NSDictionary *)dataDic;

/**
 查询

 @param entityName 实体名
 @param criterionDic 条件字典
 @return 查询结果集
 */
- (NSArray *)selectCoreDataWithEntityName:(NSString *)entityName andCriterionDic:(NSDictionary *)criterionDic;

/**
 删除

 @param entityName 实体名
 @param criterionDic 条件字典
 @return 操作结果
 */
- (CoreDataOperationResult)deleteCoreDataWithEntityName:(NSString *)entityName andCriterionDic:(NSDictionary *)criterionDic;

- (CoreDataOperationResult)updateCoreDataWithEntityName:(NSString *)entityName andCriterionDic:(NSDictionary *)criterionDic andNewDataDic:(NSDictionary *)newDataDic;

- (NSArray *)selectCoreDataWithEntityName:(NSString *)entityName andCriterionString:(NSString *)criterionString andSortKey:(NSString *)sortKey andAscending:(BOOL)ascending;

@end
